#!/bin/bash

# 拉取最新代码
git pull

# 清理
mvn clean
# 编译打包、构建镜像
./gradlew build -x javadoc -x test

name="pension-backend"

docker stop $(docker ps -a |  grep "${name}"  | awk '{print $1}')
sleep 2
docker rm -f $(docker ps -a |  grep "${name}"  | awk '{print $1}')
sleep 2
# docker run --restart always --net pension --name "${name}" -p 8080:8080 -d "${name}"
docker run --restart always --net pension --name "${name}" -d "${name}"
sleep 2
docker rmi $(docker images |grep none| awk '{print $3}')
sleep 2
docker logs -f $(docker ps -a |  grep "${name}"  | awk '{print $1}')
